package com.df.ez_game.core.layers.setting;

import com.df.ez_game.core.layers.ServerNodeSetting;
import com.df.ez_game.tools.EzConstant;
import lombok.Data;

public class NetLayerSetting extends LayerSetting{

    private boolean needServer = false;
    private Integer port;
    //网络协议
    private boolean innerNetProto = true;
    private Integer netProto = EzConstant.NetProto.WebSocket;//

    //消息协议：序列化，反序列化


    public NetLayerSetting(ServerNodeSetting owner){
        super(owner);
    }

    public ServerNodeSetting done(){
        return owner;
    }

    /**
     * 是否需要启动一个服务器来监听端口，一般需要对外(比如客户端)提供服务才用
     * @param needServer
     * @return
     */
    public NetLayerSetting isNeedServer(boolean needServer){
        this.needServer = needServer;
        return this;
    }

    /**
     * 服务的端口号。needServer 为true才生效
     * @param port
     * @return
     */
    public NetLayerSetting serverPort(Integer port){
        this.port = port;
        return this;
    }

    /**
     * 是否使用内置的网络协议,默认为true
     * @param innerNetProto
     * @return
     */
    public NetLayerSetting isInnerNetProto(boolean innerNetProto){
        this.innerNetProto = innerNetProto;
        return this;
    }

    /**
     * 使用的内置网络协议，innerNetProto 为true才生效.内置网络协议有tcp,http,websocket,udp,kcp，见 {@link EzConstant.NetProto}
     * @param netProto
     * @return
     */
    public NetLayerSetting netProto(int netProto){
        this.netProto = netProto;
        return this;
    }
}
